/*
 * GuudConfig.cpp
 *
 *  Created on: 2013-1-19
 *      Author: heqiu
 */
#include "GuudConfig.h"
namespace guud {

GuudConfig::GuudConfig() {

}
bool GuudConfig::loadFile(const char * filename) {
	m_filename = filename;
	return m_xml.LoadFile(filename);
}
bool GuudConfig::save() {
	if (m_filename.size() == 0) {
		return false;
	}
	std::string sNameBak = m_filename + ".bak";
	bool bFlag = m_xml.SaveFile(sNameBak.c_str());
	if (bFlag) {
		std::string sNameTmp = m_filename + ".tmp";
		rename(sNameBak.c_str(), sNameTmp.c_str());
		rename(m_filename.c_str(), sNameBak.c_str());
		rename(sNameTmp.c_str(), m_filename.c_str());
	}
	return true;
}

}
